﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Volo.Abp.DependencyInjection;

namespace AdminManager.Filter
{
    public class ApiDataFilter : IActionFilter, ITransientDependency
    {

        public ApiDataFilter()
        {
        }

        public void OnActionExecuted(ActionExecutedContext context)
        {
            if (context.Result is ObjectResult objrst)
            {  
                context.Result = new JsonResult(new DataResult
                {
                    Code = DataResultState.Success,
                    Message = "",
                    Result = objrst.Value
                });
            }

        }

        public void OnActionExecuting(ActionExecutingContext context)
        {
        }
    }
}
